package com.sea.app.module.identity.process.manager;

import com.sea.app.module.identity.domain.repository.UserRepository;
import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.User;
import org.activiti.engine.impl.Page;
import org.activiti.engine.impl.UserQueryImpl;
import org.activiti.engine.impl.persistence.entity.IdentityInfoEntity;
import org.activiti.engine.impl.persistence.entity.UserEntity;
import org.activiti.engine.impl.persistence.entity.UserEntityManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Component;


import java.util.List;

/**
 * Created by 31417 on 2017/4/27.
 */
@Component
public class ProcessUserEntityManager  extends UserEntityManager {

    @Autowired
    ProcessGroupEntityManager processGroupEntityManager;
    @Autowired
    UserRepository userRepository;

    @Override
    public User findUserById(String userId) {
        com.sea.app.module.identity.domain.User user = userRepository.findByNo(userId);
        if(user == null){
            return null;
        }
        UserEntity userEntity = new UserEntity();
        userEntity.setId(user.getLoginName());
        userEntity.setFirstName(user.getName());
        userEntity.setLastName(user.getNo());
        return userEntity;
    }

    @Override
    public List<Group> findGroupsByUser(String userId) {
        return processGroupEntityManager.findGroupsByUser(userId);
    }

}
